import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import {utilsMessage} from './utils/utils';

Vue.config.productionTip = false
Vue.use(ElementUI);
router.beforeEach((to, from, next) => {
  console.log(to)
  document.title = `${to.meta.title}`;
  const role = sessionStorage.getItem('ms_username');
  if (!role && to.path !== '/login') {
      utilsMessage('登录过期','warning')
      next('/login');
  } else if (to.meta.permission) {
      // 如果是管理员权限则可进入，这里只是简单的模拟管理员权限而已
      role === 'admin' ? next() : next('/403');
  } else {
    next();
  }
});
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
